﻿@using WooCoo.Web.MVC
@using WooCoo.Portal.Contracts
@{
    var userInfo = (WooCoo.ApplicationContext.User.Identity as WooCoo.Portal.Contracts.UserIdentity);
    var menuList = WooCoo.DataPortal.DataPortalClient.Default.Execute<ISupportService, IList<SysResource>>(o => o.GetUserMenuResource(userInfo.UserID));
}
<!--DOC: Set data-auto-scroll="false" to disable the sidebar from auto scrolling/focusing -->
<!--DOC: Change data-auto-speed="200" to adjust the sub menu slide up/down speed -->
<div class="page-sidebar navbar-collapse collapse" id="sidebar">
    <ul class="page-sidebar-menu" data-auto-speed="200" data-auto-scroll="false">
        <li class="sidebar-toggler-wrapper">
            <div class="sidebar-toggler hidden-phone"></div>
        </li>
        @*<li class="start">
            @Html.ActionLink("首页", "Index", "Home", new { area = "Support" }, null)
        </li>*@
        @{
            var menuGroup = menuList.Where(o => o.HasChild.Value);
            int level = 0, licout = 0;
            SysResource preRes = null;
            var emnuA = menuList.GetEnumerator();
            emnuA.MoveNext();
            while (emnuA.Current != null)
            {
                var cur = emnuA.Current;
                if (preRes != null && cur.Level < preRes.Level)
                {
                    for (int i = 0, l = preRes.Level - cur.Level; i < l; i++)
                    {
                        @Html.Raw("</ul>")
                        @Html.Raw("</li>")
                    }
                }
                @*if (preRes != null && preRes.ID != cur.ParentID && preRes.ParentID != cur.ParentID)
                    {
                        //非同个父级时
                        for (int i = level; i > 0; i--)
                        {
                            //换级
                            @Html.Raw("</ul>")
                            @Html.Raw("</li>")
                        }
                        level = 0;
                    }*@
                if (cur.HasChild.HasValue && cur.HasChild.Value)
                {
                    level++;
                    @Html.Raw("<li>")
                    <a href="javascript:;">
                        <i class="@cur.IconUrl"></i>
                        <span class="title">@cur.ResName</span>
                        <span class="arrow"></span>
                    </a>
                    @Html.Raw("<ul class=\"sub-menu\">")
                }
                else
                {
                    <li>
                        <a href="@cur.ResUrl" class="menuitem" content_id="resid_@cur.ID">
                            <i class="@cur.IconUrl"></i>
                            @cur.ResName

                        </a>
                    </li>
                }
                preRes = cur;
                emnuA.MoveNext();
            }
            //收尾
            for (int l = preRes.Level; l > 1; l--)
            {
                @Html.Raw("</ul>")
                @Html.Raw("</li>")
            }
        }
    </ul>
</div>